// 45.跳跃游戏2
package LeetcodeHot100;

public class Solution045 {
    public int jump(int[] nums) {
        int maxPosition = 0;
        int bound = 0;
        int step = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            maxPosition = Math.max(i + nums[i], maxPosition);
            if (i == bound) {
                bound = maxPosition;
                step++;
            }
        }
        return step;
    }
}
